package com.landinfo.service.impl;

import com.landinfo.service.AppMapServiceManageService;
import com.landinfo.domain.AppMapServiceManage;
import com.landinfo.repository.AppMapServiceManageRepository;
import com.landinfo.service.dto.AppMapServiceManageDTO;
import com.landinfo.service.mapper.AppMapServiceManageMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * Service Implementation for managing AppMapServiceManage.
 */
@Service
@Transactional
public class AppMapServiceManageServiceImpl implements AppMapServiceManageService{

    private final Logger log = LoggerFactory.getLogger(AppMapServiceManageServiceImpl.class);

    private final AppMapServiceManageRepository appMapServiceManageRepository;

    private final AppMapServiceManageMapper appMapServiceManageMapper;

    public AppMapServiceManageServiceImpl(AppMapServiceManageRepository appMapServiceManageRepository, AppMapServiceManageMapper appMapServiceManageMapper) {
        this.appMapServiceManageRepository = appMapServiceManageRepository;
        this.appMapServiceManageMapper = appMapServiceManageMapper;
    }

    /**
     * Save a appMapServiceManage.
     *
     * @param appMapServiceManageDTO the entity to save
     * @return the persisted entity
     */
    @Override
    public AppMapServiceManageDTO save(AppMapServiceManageDTO appMapServiceManageDTO) {
        log.debug("Request to save AppMapServiceManage : {}", appMapServiceManageDTO);
        AppMapServiceManage appMapServiceManage = appMapServiceManageMapper.toEntity(appMapServiceManageDTO);
        appMapServiceManage = appMapServiceManageRepository.save(appMapServiceManage);
        return appMapServiceManageMapper.toDto(appMapServiceManage);
    }

    /**
     *  Get all the appMapServiceManages.
     *
     *  @return the list of entities
     */
    @Override
    @Transactional(readOnly = true)
    public List<AppMapServiceManageDTO> findAll() {
        log.debug("Request to get all AppMapServiceManages");
        return appMapServiceManageRepository.findAll().stream()
            .map(appMapServiceManageMapper::toDto)
            .collect(Collectors.toCollection(LinkedList::new));
    }

    /**
     *  Get one appMapServiceManage by id.
     *
     *  @param id the id of the entity
     *  @return the entity
     */
    @Override
    @Transactional(readOnly = true)
    public AppMapServiceManageDTO findOne(Long id) {
        log.debug("Request to get AppMapServiceManage : {}", id);
        AppMapServiceManage appMapServiceManage = appMapServiceManageRepository.findOneById(id);
        return appMapServiceManageMapper.toDto(appMapServiceManage);
    }

    /**
     *  Delete the  appMapServiceManage by id.
     *
     *  @param id the id of the entity
     */
    @Override
    public void delete(Long id) {
        log.debug("Request to delete AppMapServiceManage : {}", id);
        appMapServiceManageRepository.deleteById(id);
    }
}
